package DiGui;

import javassist.expr.NewArray;

public class Recursion {
	static double count=0;
	public static double getT(int n) 
	{ 
	double i, temp;
	double a[] = {1, 1, 2}; 

	for (i = 3; i <= n; ++i) 
	{ 
	temp = a[0] + a[1] + a[2]; 
	a[0] = a[1]; 
	a[1] = a[2]; 
	a[2] = temp;
	count++;
	} 
	
	return a[2]; 
	}
	
	
	public static double knownT(double n) {
        if  (n  ==   0 )  {
        return   1 ;
        }
        else   if  (n  ==   1 )  {
	       return   1 ;
	    }
        else   if  (n  ==   2 )  {
	        return   2 ;
	    }
        else   {
	       return  knownT(n - 1 )  +  knownT(n - 2 )  +  knownT(n - 3 );
	    }  
     } 
	
	
	public static int tuiT(int n){
	       double buffer[] =null;
	       buffer[0] = 1;
	       buffer[1] = 1;
	       buffer[2] = 2; 
           for( int i = 3; i<=n; i++) 
           buffer[i] = buffer[i - 1] + buffer[i - 2] + buffer[i - 3]; 
           return (int) buffer[n];
	}
    public static void main(String[] args) {
    	 System.out.println("开始"+(System.currentTimeMillis()));
    	 System.out.println(getT(27));
    	 System.out.println("结束"+(System.currentTimeMillis()));
    	 
    	 System.out.println("开始"+(System.currentTimeMillis()));
    	 System.out.println("对比"+knownT(27));
    	 System.out.println("结束"+(System.currentTimeMillis()));
    	
	}

}
